<template>
  <div class="formulaParameter">
    <el-table
      v-if="formulaParameter && formulaParameter.length"
      max-height="500px"
      min-height="100%"
      border
      size="mini"
      :data="getDataList(formulaParameter)"
      style="width: 100%"
    >
      <el-table-column :label="'阶段'" align="center">
        <template slot-scope="scope" min-width="100">
          {{ scope.$index + 1 }}
        </template>
      </el-table-column>
      <el-table-column
        v-for="item of formulaParameter[0].keys"
        :key="item"
        align="center"
        :label="item"
        :prop="item"
        min-width="100"
      >
      </el-table-column>
    </el-table>
    <div v-else class="w100 flex-x flex-center">暂无数据</div>
  </div>
</template>

<script>
export default {
  props: {
    formulaParameter: {
      type: Array,
      default: []
    }
  },
  data() {
    return {};
  },
  methods: {
    getDataList(formulaParameter) {
      let saveFormulaParameter = [];
      formulaParameter.forEach(res => {
        let obj = {};
        res.keys.forEach((key, index) => {
          obj[key] = res.values[index];
        });
        saveFormulaParameter.push(obj);
      });
      return saveFormulaParameter;
    }
  }
};
</script>
<style lang="scss" scoped>
.formulaParameter /deep/ .el-table--mini,
.el-table--small,
.el-table__expand-icon {
  font-size: 10px !important;
  font-weight: 100 !important;
}
</style>
